package io.unicorn.modules.waterfgs.controller;

import java.util.Arrays;
import java.util.Map;

import io.unicorn.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.unicorn.modules.waterfgs.entity.DataErrFixedInfoFgsEntity;
import io.unicorn.modules.waterfgs.service.DataErrFixedInfoFgsService;
import io.unicorn.common.utils.PageUtils;
import io.unicorn.common.utils.R;



/**
 * ${comments}
 *
 * @author LNCG
 * @email LNCG@USTL.EDU.CN
 * @date 2023-04-01 09:44:54
 */
@RestController
@RequestMapping("waterfgs/dataerrfixedinfo")
public class DataErrFixedFgsInfoController {
    @Autowired
    private DataErrFixedInfoFgsService dataErrFixedInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("waterfgs:dataerrfixedinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dataErrFixedInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{opKey}")
    @RequiresPermissions("waterfgs:dataerrfixedinfo:info")
    public R info(@PathVariable("opKey") Integer opKey){
        DataErrFixedInfoFgsEntity dataErrFixedInfo = dataErrFixedInfoService.getById(opKey);

        return R.ok().put("dataErrFixedInfo", dataErrFixedInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("waterfgs:dataerrfixedinfo:save")
    public R save(@RequestBody DataErrFixedInfoFgsEntity dataErrFixedInfo){
        dataErrFixedInfoService.save(dataErrFixedInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("waterfgs:dataerrfixedinfo:update")
    public R update(@RequestBody DataErrFixedInfoFgsEntity dataErrFixedInfo){
        ValidatorUtils.validateEntity(dataErrFixedInfo);
        dataErrFixedInfoService.updateById(dataErrFixedInfo);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("waterfgs:dataerrfixedinfo:delete")
    public R delete(@RequestBody Integer[] opKeys){


        dataErrFixedInfoService.removeByIds(Arrays.asList(opKeys));

        return R.ok();
    }

}
